package com.lyl.syt.mq.receiver;/**
 * @author Mr.Luo
 * @date 2022-05-24 16:03
 */

import com.lyl.syt.rabbit.constant.MqConstant;
import com.lyl.syt.service.MsmService;
import com.lyl.syt.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Mr.Luo
 * @date 2022-05-24 16:03
 * @desc
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class MsmReceiver {
    private final MsmService aliYunSmsService;

    @RabbitListener(
            bindings = {
                    @QueueBinding(value = @Queue(value = MqConstant.MSM_QUEUE,durable = "true"),
                            exchange = @Exchange(value = MqConstant.MSM_EXCHANGE),
                            key = MqConstant.MSM_ROUTING)
            }
    )
    public void sendMsmMsg(MsmVo msmVo, Message message, Channel channel){
        log.info("接受到[{}]队列的消息，消息内容是: {} " , MqConstant.MSM_QUEUE, msmVo);
        aliYunSmsService.send(msmVo);
    }

}
